<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 */

class Modules_Seo_Hooks_Gatracker_Hook extends Gio_Core_Hook
{
	public function __construct()
	{
		parent::__construct();
	}
	
	/**
	 * @return void
	 */
	public function action()
	{
		$code = $this->getParam('code');
		if (null == $code) {
			return;
		}
		$code = trim($code);
		if ($code != '') {
			echo <<<END
<script type="text/javascript">
	var _gaq = _gaq || [];
  	_gaq.push(['_setAccount', '$code']);
  	_gaq.push(['_trackPageview']);
  	(function() {
    	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  	})();
</script>
END;
		}
	}
}
